import { useUserStoreExternal } from "@/store/useUserStore";
import { BASE_URL } from "@/config/constants";
import { reactive } from "vue"
import { ElMessage, type UploadUserFile } from "element-plus";

let userStore = useUserStoreExternal()
export function useUpload() {
  let uploadCfg = reactive({
    uploadUrl: BASE_URL + '/storage/uploadFile',
    headers: {
      "Authorization": userStore.token
    }
  })

  //files:已上传的文件列表,每个file元素都是"结构1",fileList:超出的文件列表
  function handleExceed(files:File[], fileList:UploadUserFile[]) {
    ElMessage({ message: `数量超出限制,只能上传${files.length}个`, type: "error" });
  }
  return { uploadCfg,handleExceed }
}
